package com.ninth_group.config;

import com.ninth_group.utils.HBaseServiceUtil;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;


@Configuration
public class HBaseConfig {

    @Value("${hbase.zookeeper.quorum}")
    private String zookeeperQuorum;
    @Value("${hbase.zookeeper.property.clientPort}")
    private String clientPort;
    @Value("${zookeeper.znode.parent}")
    private String zNodeParent;

    @Bean
    public HBaseServiceUtil getHbaseService() throws IOException {
        org.apache.hadoop.conf.Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum", zookeeperQuorum);
        conf.set("hbase.zookeeper.property.clientPort", clientPort);
        conf.set("zookeeper.znode.parent", zNodeParent);
        return new HBaseServiceUtil(conf);
    }

}
